package net.cyndeline.entitySystem

import scala.collection.immutable.Stack
import java.util.Collection

trait IdManager {
  
  /**
   * The next available entity id. May modify the managers state, and will
   * only be used to retrieve an id for immediate use.
   */
  def getNext: Int
  
  /**
   * Returns the next available id without modifying the manager state.
   */
  def viewNext: Int
  
  /**
   * Sets an id as the next to be returned (as long as no free id exists).
   */
  def setNext(id: Int): Unit
  
  /**
   * Marks an id as free to assign again.
   */
  def freeId(id: Int): Unit
  
  /**
   * Returns the collection of free id's, used to save the game state.
   */
  def getFreeIds: List[Int]
  
  /**
   * Sets a set of entity id's as free, overrides the current collection.
   */
  def setFreeIds(ids: List[Int]): Unit
  
  /**
   * Checks if an id is stored in the set of previously used ids.
   */
  def isAvailable(id: Int): Boolean
  
  /**
   * Reset the manager values.
   */
  def clear: Unit
  
}

object IdManager {
  val NULL_ID: Int = 0
}